#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char s[1000],a[1000][100],w[100];
    printf("Enter a sentence: ");
    gets(s);
    int i=0,j=0,k=0,t,f=0;
    while(s[i]!='.'&&s[i]!='!'&&s[i]!='?')
    {
        while(s[i]==' ')
        {
            i++;
        }
        if(s[i]=='.'||s[i]=='!'||s[i]=='?')
            {f--;break;}
        while(s[i]!=' ')
        {
            a[f][j]=s[i];
            i++;
            j++;
            if(s[i]=='.'||s[i]=='!'||s[i]=='?')
            {
                a[f][j]='\0';
                {break;}
            }
        }
        if(s[i]=='.'||s[i]=='!'||s[i]=='?')
        {break;}
        a[f][j]='\0';
        j=0;
        f++;
    }
    printf("Reversal of sentence:");
    for(t=f;t>0;t--)
    {
        printf("%s ",a[t]);
    }
    printf("%s",a[0]);
    printf("%c",s[i]);
    return 0;
}
